<?php
namespace Admin\Model;
use Think\Model;
class UserModel extends Model {

	public function loginout($type){

	    	switch($type){
	    		case '1':
	    			$message='退出成功';
	    			break;
	    		case '2':
	    			$message='未登录状态禁止访问';
	    			break;
	    		case '3':
	    			$message='更行成功，请重新登陆';
	    			break;
	    		default:
	    			$message='网络错误请重新登陆';
	    			# code...
	    			break;
	    	}
	    	session(null);
	    	return $message;
	}

	/**
	 *
	 * 图片上传
	 * 
	 */
	public function upload_img($fileimg){
			$file = $_FILES['file'];
			$name = $file['name'];
			$type = strtolower(substr($name,strrpos($name,'.')+1)); 
			$allow_type = array('jpg','jpeg','gif','png'); 
			if(!in_array($type, $allow_type)){
				$mes['code']=2;
				$mes['message']="文件类型不是允许上传类型";
			}
			if(!is_uploaded_file($file['tmp_name'])){
				$mes['code']=1;
				$mes['message']="不是通过HTTP POST上传";
			}
			$upload_path = "Uploads/";
			if(move_uploaded_file($file['tmp_name'],$upload_path.$fileimg."/".time().$name)){
				$mes['code']=1;
				$mes['message']=$upload_path.$fileimg."/".time().$name;
				return $mes;
			
			}	
	}

}